import request from '../../utils/request'
Page({
  data: {
    bannerList:[],
    recommendList:[],
    topList:[]
  },
 onLoad: async function(option){
    let bannerListData= await request ('/banner',{type:2})
    // console.log(bannerList);
    this.setData({
      bannerList:bannerListData.banners
    })

    //获取推荐歌单数据
    let recommendListData =await request('/personalized',{limit:10})
    this.setData({
      recommendList:recommendListData.result
    })

    //获取排行榜数据
    let index=0;
    let resultArr=[];
    while (index < 5){
      let topListData =await request('/top/list',{idx:index++});
      let topListItem={name:topListData.playlist.name,tracks:topListData.playlist.tracks.slice(0,3)};
      resultArr.push(topListItem)
      this.setData({
        topList:resultArr
      })
    }
 },
 //跳转至recommendSong页面的回调
  toRecommendSong(){
    wx.navigateTo({
      url: '/pages/recommendSong/recommendSong'
  })
}
})
